package com.literature.search.core.entity;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.io.Serializable;
import java.util.Base64;

@Data
@Document(collection = "picture_parse")
public class PictureParse  implements Serializable {

    private static final long serialVersionUID = 1L;


    /**
     * 文档Id
     */
    @Field("file_id")
    @ApiModelProperty(value = "所属文档Id")
    private String fileId;

    /**
     * 大文件管理GridFS的ID
     */
    @Field("gridfs_id")
    @ApiModelProperty(value = "大文件管理GridFS的ID")
    private String gridfsId;


    /**
     * 图片所在文档的页码数
     */
    @Field("page_num")
    @ApiModelProperty(value = "图片所在文档的页码数")
    private Integer pageNum;

    /**
     * ocr识别出来的文字内容
     */
    @Field("ocr_content")
    @ApiModelProperty(value = "ocr识别出来的文字内容",notes = "文件转化成base64编码")
    private String ocrContent = "";



    public void readOCRContent(String ocrContent) {
        //将文件内容转化为base64编码
        this.ocrContent = Base64.getEncoder().encodeToString(ocrContent.getBytes());
    }

}
